home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource4 / 228_01 / isamdel.c < prev    next >
Text File  |  1987-07-31  |  1KB  |  58 lines

  1. /*
  2. HEADER:         CUGXXX;
  3. TITLE:          Delete record (of ISAM system);
  4. DATE:           3-31-86;
  5. DESCRIPTION:    Part of ISAM Library;
  6. KEYWORDS:       ISAM;
  7. FILENAME:       ISAMDEL.C;
  8. WARNINGS:       None;
  9. AUTHORS:        John M. Dashner;
  10. COMPILER:       Lattice C;
  11. REFERENCES:     US-DISK 1310;
  12. ENDREF
  13. */
  14. /*
  15. **                 ISAMC - Written by John M. Dashner
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <ctype.h>
  20.  
  21. #include <isam.h>
  22.  
  23. /*
  24. **                  DELETE - Mark Index Record Deleted
  25. */
  26.  
  27. isamdel(hdr)
  28. struct isam *hdr;
  29. {
  30.     char buf[MAXKEY + 2];
  31.     long lrecl;
  32.     struct rec3 *r3;
  33.     r3 = (struct rec3 *) buf;
  34.  
  35.     if ((hdr->q4 < 2) || (hdr->q4 >= hdr->q3))
  36.     {
  37.         isam_err = 2;
  38.         return ERROR;
  39.     }
  40.     lrecl = hdr->q4 * (hdr->q6 + 2);
  41.     lseek(hdr->q7, lrecl, 0);
  42.     if (read(hdr->q7, buf, hdr->q6 + 2) == ERROR)
  43.     {
  44.         isam_err = 8;
  45.         return ERROR;
  46.     }
  47.     r3->idx_key[0] = 255;       /* post as deleted */
  48.     lseek(hdr->q7, lrecl, 0);
  49.     if (write(hdr->q7, buf, hdr->q6 + 2) == ERROR)
  50.     {
  51.         isam_err = 8;
  52.         return ERROR;
  53.     }
  54.     hdr->q2 += 1;               /* bump delete count */
  55.     return NULL;
  56. }
  57.  
  58.